

/**
 * 用户列表
 */
let MemberListView = class MemberListView{
    /**
     * 页面元素ID
     */
    id = "body"
    /**
     * 视图名字
     */
    name = "用户列表"
    /**
     * 页面标题
     */
    title = "用户列表"
    /**
     * 页面数据
     */
    data = [
        {
            "guid":"00000000",
            "emailAddress":"test",
            "emailType":"163.com",
            "emailVerTime":0,

            "mobileNumber":"18912345678",
            "mobileNation":"86",
            "mobileVerTime":0,
        },
        {
            "guid":"00000000",
            "emailAddress":"test",
            "emailType":"163.com",
            "emailVerTime":1,

            "mobileNumber":"18912345678",
            "mobileNation":"86",
            "mobileVerTime":0,
        }
    ]
    /**
     * html 页面
     */
    innerHTML = ''

    /**
     * 构造函数
     */
    constructor(_data = null){

        var member_list = ''
        for (let n in this.data) {
            

            member_list += `
                <tr>
                    <td>` + this.data[n].guid + `</td>
                    <td>` + this.emailInnerHTML(this.data[n]) + `</td>
                    <td>` + this.mobileInnerHTML(this.data[n]) + `</td>
                    <td>` + this.data[n].guid + `</td>
                    <td>
                        <a href="#">详情</a>
                        <a href="#">修改</a>
                        <a href="#">身份</a>
                    </td>
                </tr>
            `
        }

        this.innerHTML = `
        <div id="member_list">
            <table>
                <thead>
                  <tr>
                    <th>用户ID</th>
                    <th>邮箱</th>
                    <th>手机</th>
                    <th>实名</th>
                    <th>管理</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                  </tr>
                  `+ member_list +`
                </tbody>
            </table>
        </div>
        `
    }

    /**
     * 处理email显示
     * @param {*} Member 
     */
    emailInnerHTML(Member){
        let innerHTML = '';
        let email = ''
        let emailVer = ''
        if(Member.emailAddress != ''){
            email = Member.emailAddress +'@'+ Member.emailType
            if(Member.emailVerTime){
                emailVer = '<span>已验证</span>'
            }else{
                emailVer = '<span>未验证</span>'
            }
        }
        innerHTML = email + ' ' + emailVer
        return innerHTML
    }
    /**
     * 处理mobile显示
     * @param {*} Member 
     */
    mobileInnerHTML(Member){
        let innerHTML = '';
        let mobile = ''
        let mobileVer = ''
        if(Member.emailAddress != ''){
            mobile = '(' + Member.mobileNation +') '+ Member.mobileNumber
            if(Member.mobileVerTime){
                mobileVer = '<span>已验证</span>'
            }else{
                mobileVer = '<span>未验证</span>'
            }
        }
        innerHTML = mobile + ' ' + mobileVer
        return innerHTML
    }


}

export default MemberListView

